package com.ruoyi.tccs.tccs_ri_estimate.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.tccs.tccs_ri_estimate.domain.TccsRiEstimate;
import com.ruoyi.tccs.tccs_ri_estimate.service.ITccsRiEstimateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * RI值参考Controller
 *
 * @author RenZhengYang
 * @date 2024-04-07
 */
@RestController
@RequestMapping("/tccs/tccs_ri_estimate")
public class TccsRiEstimateController extends BaseController
{
    @Autowired
    private ITccsRiEstimateService tccsRiEstimateService;

    /**
     * 查询RI值参考列表
     */
    @PreAuthorize("@ss.hasPermi('tccs:tccs_ri_estimate:list')")
    @GetMapping("/list")
    public TableDataInfo list(TccsRiEstimate tccsRiEstimate)
    {
        startPage();
        List<TccsRiEstimate> list = tccsRiEstimateService.selectTccsRiEstimateList(tccsRiEstimate);
        return getDataTable(list);
    }

    /**
     * 导出RI值参考列表
     */
    @PreAuthorize("@ss.hasPermi('tccs:tccs_ri_estimate:export')")
    @Log(title = "RI值参考", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TccsRiEstimate tccsRiEstimate)
    {
        List<TccsRiEstimate> list = tccsRiEstimateService.selectTccsRiEstimateList(tccsRiEstimate);
        ExcelUtil<TccsRiEstimate> util = new ExcelUtil<TccsRiEstimate>(TccsRiEstimate.class);
        util.exportExcel(response, list, "RI值参考数据");
    }

    /**
     * 获取RI值参考详细信息
     */
    @PreAuthorize("@ss.hasPermi('tccs:tccs_ri_estimate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tccsRiEstimateService.selectTccsRiEstimateById(id));
    }

    /**
     * 新增RI值参考
     */
    @PreAuthorize("@ss.hasPermi('tccs:tccs_ri_estimate:add')")
    @Log(title = "RI值参考", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TccsRiEstimate tccsRiEstimate)
    {
        tccsRiEstimate.setCreateBy(getUsername());
        return toAjax(tccsRiEstimateService.insertTccsRiEstimate(tccsRiEstimate));
    }

    /**
     * 修改RI值参考
     */
    @PreAuthorize("@ss.hasPermi('tccs:tccs_ri_estimate:edit')")
    @Log(title = "RI值参考", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TccsRiEstimate tccsRiEstimate)
    {
        tccsRiEstimate.setUpdateBy(getUsername());
        return toAjax(tccsRiEstimateService.updateTccsRiEstimate(tccsRiEstimate));
    }

    /**
     * 删除RI值参考
     */
    @PreAuthorize("@ss.hasPermi('tccs:tccs_ri_estimate:remove')")
    @Log(title = "RI值参考", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tccsRiEstimateService.deleteTccsRiEstimateByIds(ids));
    }
}
